using System;
using System.Security.Cryptography;

internal class Class_i : IDisposable
{
	private HMAC m_a;

	private byte[] m_b;

	private int c;

	private readonly int d;

	private uint e = 1u;

	private byte[] f;

	private int g;

	private int h;

	internal Class_i(HMAC A_0, byte[] A_1, int A_2)
	{
		if (A_0 == null)
		{
			throw new ArgumentNullException("algorithm", "Algorithm cannot be null.");
		}
		if (A_1 != null)
		{
			try
			{
				this.m_a = A_0;
				this.m_b = A_1;
				c = A_2;
				d = this.m_a.HashSize / 8;
				f = new byte[d];
			}
			catch
			{
				if (this.m_a != null)
				{
					this.m_a.Clear();
					this.m_a.Dispose();
				}
				throw;
			}
			return;
		}
		throw new ArgumentNullException("salt", "Salt cannot be null.");
	}

	~Class_i()
	{
		Dispose();
	}

	public void Dispose()
	{
		b();
	}

	internal void b()
	{
		if (this.m_a != null)
		{
			this.m_a.Clear();
			this.m_a.Dispose();
		}
	}

	internal byte[] a(int A_0)
	{
		byte[] array = new byte[A_0];
		int i = 0;
		int num = h - g;
		if (num > 0)
		{
			if (A_0 < num)
			{
				Buffer.BlockCopy(f, g, array, 0, A_0);
				g += A_0;
				return array;
			}
			Buffer.BlockCopy(f, g, array, 0, num);
			g = (h = 0);
			i += num;
		}
		for (; i < A_0; i += d)
		{
			byte[] src = a();
			int num2 = A_0 - i;
			if (num2 > d)
			{
				Buffer.BlockCopy(src, 0, array, i, 20);
				continue;
			}
			Buffer.BlockCopy(src, 0, array, i, num2);
			i += num2;
			Buffer.BlockCopy(src, num2, f, g, d - num2);
			h += d - num2;
			return array;
		}
		return array;
	}

	private byte[] a()
	{
		byte[] array = a(e);
		this.m_a.TransformBlock(this.m_b, 0, this.m_b.Length, this.m_b, 0);
		this.m_a.TransformFinalBlock(array, 0, array.Length);
		byte[] array2 = this.m_a.Hash;
		this.m_a.Initialize();
		byte[] array3 = array2;
		for (int i = 2; i <= c; i++)
		{
			array2 = this.m_a.ComputeHash(array2);
			for (int j = 0; j < d; j++)
			{
				array3[j] = (byte)(array3[j] ^ array2[j]);
			}
		}
		e++;
		return array3;
	}

	private static byte[] a(uint A_0)
	{
		byte[] bytes = BitConverter.GetBytes(A_0);
		if (BitConverter.IsLittleEndian)
		{
			return new byte[4]
			{
				bytes[3],
				bytes[2],
				bytes[1],
				bytes[0]
			};
		}
		return bytes;
	}
}
